package pso;

public class BoundaryHandlerStikyWall implements BoundaryHandler {
	Point lowerBound, upperBound;
	
	public BoundaryHandlerStikyWall(Point lowerBound, Point upperBound) {
		this.lowerBound = lowerBound;
		this.upperBound = upperBound;
	}

	@Override
	public void applyBoundaryHandling(Particle p) {
		Point pos = p.getPosition();
		for(int i = 0; i < pos.getDimension(); ++i){
			if(pos.getCoordinate(i) < lowerBound.getCoordinate(i)){
				pos.setCoordinate(i, lowerBound.getCoordinate(i));
			}
			if(pos.getCoordinate(i) > upperBound.getCoordinate(i)){
				pos.setCoordinate(i, upperBound.getCoordinate(i));
			}
		}
	}

}
